package com.kexuexiong.mybatisplus;

import cn.hutool.core.codec.Base64;
import cn.hutool.jwt.JWTUtil;

import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;

/**
 * <p>功能描述</p>
 *
 * @author xy
 * @version 1.0
 * @ClassName JWTDemo.java
 * @date 2021年11月2021/11/29日 18:06
 */
public class JWTDemo {
    public static void main(String[] args) throws UnsupportedEncodingException {
//        Map<String, Object> map = new HashMap<String, Object>() {
//            private static final long serialVersionUID = 1L;
//            {
//                put("uid", Integer.parseInt("123"));
//                put("expire_time", System.currentTimeMillis() + 1000*10);
//            }
//        };
//
//        String token = JWTUtil.createToken(map, "1234".getBytes());
////        System.out.println(token);
//        byte[] decode = Base64.decode("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHBpcmVfdGltZSI6MTYzODE4MDc4NTYxMCwidWlkIjoxMjN9.7f0691bee2b2a3efec8c33a555908a282ae74ae24854250f9f606704678c9a52");
//        String s = new String(decode, "utf-8");
//        System.out.println(s);
        String token ="eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHBpcmVfdGltZSI6MTYzODE4MDc4NTYxMCwidWlkIjoxMjN9.7f0691bee2b2a3efec8c33a555908a282ae74ae24854250f9f606704678c9a52";
        boolean verify = new JWTUtil().verify(token, "123456".getBytes());
        System.out.println(verify);

    }
}
